package com.oauth2.Enum;

public enum GrantTypeEnum {
	AUTHORIZATION_CODE("Authorization Code","authorization_code"),
	IMPLICIT("Implicit","implicit"),
	PASSWORD("Password","password"),
	CLIENT_CREDENTIALS("Client Credentials","client_credentials"),
	REFRESH_TOKEN("Refresh Token","refresh_token");
	
	private String text;
	private String code;
	private GrantTypeEnum(String text, String code) {
		this.text = text;
		this.code = code;
	}
	
	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public static String getGrantTypeEnumByCode(String code){
		for(GrantTypeEnum type:GrantTypeEnum.values()){
			if(code.equals(type.code)){
				return type.text;
			}
		}
		return null;
	}

}
